package com.chz.SupermarketMS.dao;


import com.chz.SupermarketMS.dto.SaleHeads;
import com.chz.SupermarketMS.entities.Sale;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SaleRepository extends CrudRepository<Sale, Long> {

    @Override
     List<Sale> findAll();

    @Query(nativeQuery = true,value = "SELECT s.sale_id as saleId, h.name as name, s.data as data  " +
            "FROM chz.sale s left join chz.head h on s.head_id = h.head_id;"
    )
    List<SaleHeads> saleHeads();

    Sale findBySaleId(long theId);
}
